package com.example.fragment;

import java.io.File;

import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;

import com.example.drawer.MainActivity;
import com.example.drawer.R;

public class VideoFragment extends Fragment {
	private ImageButton button;
	protected static final int CAMERA_RESULT = 0;
	private String imageFilePath;

	@Override
	public View onCreateView(LayoutInflater inflater,
			@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View view = inflater.inflate(R.layout.video, null);
		button = (ImageButton) view.findViewById(R.id.button1);
		button.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				imageFilePath = Environment.getExternalStorageDirectory()
						.getAbsolutePath() + "/mypicture.jpg";
				File imageFile = new File(imageFilePath);
				Uri imageFileUri = Uri.fromFile(imageFile);

				Intent i = new Intent(
						android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
				i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
						imageFileUri);
				startActivityForResult(i, CAMERA_RESULT);

			}
		});
		return view;
	}

	@Override
	public void onAttach(Activity activity) {
		// TODO Auto-generated method stub
		super.onAttach(activity);
		((MainActivity) activity).onSectionAttached(2);
	}

}
